﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class UIGuideOpen : UIObject
{
    public Transform hand;
    public Transform cup;
    public Transform dice;
    // Start is called before the first frame update
    protected override void onVisible()
    {
        base.onVisible();
        Open();
    }

    Sequence _sequence;
    protected override void OnInvisible()
    {
        base.OnInvisible();
        _sequence.Kill();
    }


    private void Open()
    {
        this.transform.localPosition = new Vector3(0, 500, 0);
        dice.localScale = Vector3.zero;//隐藏筛子
        cup.localEulerAngles = Vector3.zero;
        Sequence s = DOTween.Sequence(this.gameObject);
        s.AppendInterval(14.5f);
        s.Append(this.transform.DOLocalMove(Vector3.zero, 1));

        //手指按下
        s.Append(hand.DOLocalRotate(new Vector3(0, 0, -30), 0.1f));
        s.Append(hand.DOLocalRotate(new Vector3(0, 0, 10), 1));

        s.Append(cup.transform.DOLocalRotateQuaternion(Quaternion.Euler(0, 0, 90), 0.2f));//打开盖子
        s.Append(dice.DOScale(Vector3.one, 0.2f));//骰子显示
        s.AppendInterval(1);
        s.Append(this.transform.DOLocalMove(new Vector3(0, 500, 0), 1));

        //设置次数
        //s.SetLoops(4, LoopType.Yoyo);
        _sequence = s;
    }

}
